package com.example.test;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

@SpringBootApplication
public class TestApplication {

    public static void main(String[] args) {
        Format("[{\"type\":string,\"field\":cat,value:\"123\"\"\"},{\"type\":string,\"field\":cat,value:\"123\"\"\"}]");
        SpringApplication.run(TestApplication.class, args);
    }


    public  static  String Format (String str){
        Pattern pattern= Pattern.compile("(?<=value).*?(?=\"\\s*\\}\\s*,\\s*\\{|\"\\s*\\}\\s*\\])");
        Matcher m = pattern.matcher(str);
        while (m.find()){
            String mat = m.group(0);
            mat = mat.substring(mat.indexOf("\"")+1);
            var rep = mat.replace("\\","\\\\").replace("\"","\\\"");
            str = str.replace(mat,rep);
        }
        return  "";
    }

}
